package lingnan.cn.edu.Table;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import lingnan.cn.edu.BaseAndImpl.StaffManageService;
import lingnan.cn.edu.User.Staffinf;
import lingnan.cn.edu.service.StaffManageServiceImpl;

public class StaffManageTableModel extends AbstractTableModel{
private String [] columnName = {"员工姓名","密码","权限"};
	
	private StaffManageService staffservice = new StaffManageServiceImpl();
	
	private List<Staffinf> staffs;
	
	public void query() {
		staffs = staffservice.query();
	}
	
	public void findStaff(String staffname) {
		staffs = staffservice.findStaff(staffname);
	}
	@Override
	public int getRowCount() {
		return staffs.size();
	}

	@Override
	public int getColumnCount() {
		return columnName.length;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		Staffinf staff = staffs.get(rowIndex);
		if(columnIndex==0) {
			return staff.getStaffName();
		}
		else if(columnIndex==1) {
			return staff.getPassword();
		}
		else if(columnIndex==2) {
			return staff.getStaffSuper();
		}else {
			return null;
		}
	}
	
	@Override
	public String getColumnName(int column) {
		return columnName[column];
	}
}
